﻿using ArticleContentCreate.Utils.View;
using CatUtils.Utils.Currency.IoUtils;
using CatUtils.Utils.Helper;
using System.Windows.Forms;

namespace ArticleContentCreate.ViewManger
{
    internal class ViewReplace
    {
        internal void SelectChange(GroupBox groupBox1, string ModeText)
        {
            SelectIndexSave(ModeText);
            switch (ModeText)
            {
                case "P站画师":
                    new Groupboxhelper().Replace(groupBox1, new PixivArtControl());
                    break;

                case "P站图集":
                    new Groupboxhelper().Replace(groupBox1, new ComicImgControl());
                    break;

                case "动漫信息":
                    new Groupboxhelper().Replace(groupBox1, new ComicInfo());
                    break;
            }
        }

        private string ModeSaveFile = StaticValue.BinPath + "SelectMode";

        public void SelectIndexGet(GroupBox groupBox)
        {
            string ModeText = FileHelper.ReadAllText(ModeSaveFile);
            new ViewReplace().SelectChange(groupBox, ModeText);
        }

        /// <summary>
        /// 保存信息到数据库
        /// </summary>
        /// <param name="Mode"></param>
        public void SelectIndexSave(string Mode)
        {
            FileHelper.WriteText(ModeSaveFile, Mode);
        }
    }
}